package com.java.core1.chapter3;

import java.util.Objects;


/**
* @author ClearScenery
* @version 创建时间：2019年3月7日 上午10:57:56
* @ClassName StringTest2
* @Description 测试字符串和其他引用型数据的区别
*/
public class StringTest2 {
	
	public static void testStrOrObj(String str,int [] nums) {
//		str = "world";
		str = new String("world");
		nums[2] = 0;
//		Objects 1.7出的工具类
	}
	
	public static void main(String[] args) {
		//test1
//		String str = "hello";
		int nums [] = {1,2,3};//nums[2]=3
//		testStrOrObj(str,nums);
//		System.out.println(str);//hello
//		System.out.println(nums[2]);//0
//		
		String str2 = new String("hello");
		testStrOrObj(str2,nums);
		System.out.println(str2);//hello
		
		//test2
//		Integer i = 0;
//		Double d = 0.0;
//		Long l = 0l;
//		Character c = '0';
//		testStrOrObj( i, d, l, c);
//		System.out.println(i);//0
//		System.out.println(d);//0.0
//		System.out.println(l);//0
//		System.out.println(c);//0
//		
//		Integer i2 = new Integer(0);
//		Double d2 = new Double(0.0);
//		Long l2 = new Long(0l);
//		Character c2 = new Character('0');
//		testStrOrObj( i2, d2, l2, c2);
//		System.out.println(i2);//0
//		System.out.println(d2);//0.0
//		System.out.println(l2);//0
//		System.out.println(c2);//0
		
		//test3
	    StringBuffer sbr = new StringBuffer("test");
	    System.out.println(sbr.toString());
	    testStringParam1(sbr);
	    System.out.println(sbr.toString());
	    testStringParam2(sbr);
	    System.out.println(sbr.toString());
	}
	 
	 
	public static void testStringParam1(StringBuffer sbr){
		//修改引用参数
	    sbr.delete(0,sbr.capacity()).append("test111");
	}
	 
	 
	public static void testStringParam2(StringBuffer sbr){
		//从新初始化引用参数
	    sbr = new StringBuffer(sbr.append("222"));

	}
	
//	public static void testStrOrObj(Integer i,Double d,Long l,Character c) {
//		i = 1;
//		d = 1.0;
//		l = 1l;
//		c = '1';
//	}

}
